home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Networking & Communications / Serial NB Sample Driver / Task / inc / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  2.4 KB  |  112 lines  |  [TEXT/MPS ]

  1. /********************************************************************************/
  2. /*                                                                                */
  3. /*        main.c - Serial NB (what a stupid name) asynchronous driver.            */
  4. /*                                                                                */
  5. /*        Richard W. Mincher.  February 19, 1990.                                    */
  6. /*                                                                                */
  7. /*        Copyright © 1990, Apple Computer, Inc.  All rights reserved.            */
  8. /*                                                                                */
  9. /*                                                                                */
  10. /*        DISCLAIMER:  Don't blame me for the serial driver interface.            */
  11. /*                                                                                */
  12. /********************************************************************************/
  13.  
  14. #define        MAIN
  15.  
  16. #include    "AROSE.h"
  17. #include    "os.h"
  18. #include    "managers.h"
  19.  
  20. #include    "ARDriver.h"
  21. #include    "ARTask.h"
  22.  
  23. long    GetA5()     extern 0x200d;
  24. main()
  25. {
  26.     tid_type        temp;
  27.     long            a5;
  28.     unsigned char    *c;
  29.     
  30.     a5 = GetA5();
  31.     G->tbeCount = G->srcCount = G->escCount = G->rcaCount = 0;
  32. #ifdef    DEBUG
  33.     printf("SNBTask starting.  port = %d;  a5 = %x\n", PORT, a5);
  34. #endif    DEBUG
  35.  
  36.     c = GetStParms();
  37.     BlockMove( &c[1], (char *)0x700, c[0] );
  38.     InitTask();
  39.     while(open)
  40.     {
  41.         if (msg = Receive( 0, 0, 0, 20 ))
  42.         {
  43. #ifdef    DEBUG
  44.             printf("msg: mCode=%x; mFrom=%x; mDataPtr=%x; mDataSize=%x; mStatus=%x\n",
  45.                 msg->mCode, msg->mFrom, msg->mDataPtr, msg->mDataSize, msg->mStatus );
  46. #endif    DEBUG
  47.             reply = 1;
  48.             switch( msg->mCode )
  49.             {
  50.                 case    SNBOpen:
  51.                     OpenCall();
  52.                     break;
  53.                 case    SNBClose:
  54.                     CloseCall();
  55.                     break;
  56.                 case    SNBRead:
  57.                     reply = 0;
  58.                     ReadCall();
  59.                     break;
  60.                 case    SNBWrite:
  61.                     reply = 0;
  62.                     WriteCall();
  63.                     break;
  64.                 case    SNBControl:
  65.                     ControlCall();
  66.                     break;
  67.                 case    SNBStatus:
  68.                     StatusCall();
  69.                     break;
  70.                 case    1000:                /*    Write interrupt */
  71.                     reply = 0;
  72.                     G->txSignal = msg;
  73.                     TickleWrite();
  74.                     break;
  75.                 case    2000:                /*    Read interrupt    */
  76.                     reply = 0;
  77.                     G->rxSignal = msg;
  78.                     TickleRead();
  79.                     break;
  80.                 default:
  81. #ifdef    DEBUG
  82.                     printf("default: mCode=%x; mFrom=%x; mTo=%x; mStatus=%x\n",
  83.                         msg->mCode, msg->mFrom, msg->mTo, msg->mStatus );
  84. #endif    DEBUG
  85.                     msg->mCode |= 0x8000;
  86.                     break;
  87.             }
  88.             if (reply)
  89.             {
  90.                 temp = msg->mFrom;
  91.                 msg->mFrom = msg->mTo;
  92.                 msg->mTo = temp;
  93.                 msg->mCode |= 1;
  94.                 Send( msg );
  95. #ifdef    DEBUG
  96.                 printf("Reply sent.\n");
  97. #endif    DEBUG
  98.             }
  99.         }
  100.         else
  101.         {
  102.             TickleRead();
  103.             TickleWrite();
  104.         }
  105.     }
  106. #ifdef    DEBUG
  107.     printf("ARTask exiting.\n");
  108.     printf("tbeCount = %d, rcaCount=%d, escCount=%d, srcCount=%d\n",
  109.         G->tbeCount, G->rcaCount, G->escCount, G->srcCount );
  110. #endif    DEBUG
  111. }
  112.